<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>自定义的路由demo</title>
  <!-- 开发环境版本，包含了有帮助的命令行警告 -->
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  <style type="text/css">
    #app{
      margin: 40px auto;
      width: 800px;
      text-align: center;
    }
  </style>
</head>
<body>
  <div id="app">
    <div>
      <router-link to="/">首页</router-link>
      <router-link to="/about">关于我们</router-link>
    </div>
    <router-view/>
  </div>

  <script src="./myVueRouter/index.js"></script>
  <script>
    window.onload = function() {
      Vue.use(MyRouter)

      const router = new MyRouter({
        router: [
          {
            path: '/',
            components: {
              name: 'home',
              template: '<div>{{name}}</div>',
              data() {
                return {
                  name: 'home'
                }
              }
            }
          }, {
            path: '/about',
            components: {
              name: 'about',
              template: '<div>{{name}}</div>',
              data() {
                return {
                  name: 'about'
                }
              }
            }
          }
        ]
      })
      var app = new Vue({
        el: '#app',
        router: router,
        data: {
          message: 'Hello Vue!'
        }
      })
    }();
  </script>
</body>
</html>